package com.huanmeiqi.forkjoin.service;

import com.huanmeiqi.forkjoin.vo.Color;
import com.huanmeiqi.forkjoin.vo.Peach;
import com.huanmeiqi.forkjoin.vo.Size;

import java.util.concurrent.TimeUnit;

/**
 * @author cq.Wang
 * @date 2018/8/7 15:45
 * @description
 */
public class MonkeyKing {


    public MonkeyKing() {
    }

    /**
     * 摘桃
     *
     * @param index
     * @return
     */
    public boolean pickPeach(Peach[] array, Integer index) {
        Peach peach = array[index];
        // 孙悟空只摘大的、红色且6000年以上熟的桃子
        if (peach.getColor() == Color.RED && peach.getSize() == Size.BIG && peach.getYear() >= 6000) {
            return true;
        }
        return false;
    }

    /**
     * 把桃子放到包里
     */
    public void putBag(Peach[] array, Integer index) {
        try {
            System.out.println("将桃放入包裹中->" + array[index]);
            TimeUnit.MILLISECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
